package com.ruoyi.web.controller.business;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TPrescriptionNurseHis;
import com.ruoyi.system.service.ITPrescriptionNurseHisService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 护士处置记录Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@Controller
@RequestMapping("/system/his")
public class TPrescriptionNurseHisController extends BaseController
{
    private String prefix = "system/his";

    @Autowired
    private ITPrescriptionNurseHisService tPrescriptionNurseHisService;

    @RequiresPermissions("system:his:view")
    @GetMapping()
    public String his()
    {
        return prefix + "/his";
    }

    /**
     * 查询护士处置记录列表
     */
    @RequiresPermissions("system:his:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(TPrescriptionNurseHis tPrescriptionNurseHis)
    {
        startPage();
        List<TPrescriptionNurseHis> list = tPrescriptionNurseHisService.selectTPrescriptionNurseHisList(tPrescriptionNurseHis);
        return getDataTable(list);
    }

    /**
     * 导出护士处置记录列表
     */
    @RequiresPermissions("system:his:export")
    @Log(title = "护士处置记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TPrescriptionNurseHis tPrescriptionNurseHis)
    {
        List<TPrescriptionNurseHis> list = tPrescriptionNurseHisService.selectTPrescriptionNurseHisList(tPrescriptionNurseHis);
        ExcelUtil<TPrescriptionNurseHis> util = new ExcelUtil<TPrescriptionNurseHis>(TPrescriptionNurseHis.class);
        return util.exportExcel(list, "护士处置记录数据");
    }

    /**
     * 新增护士处置记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存护士处置记录
     */
    @RequiresPermissions("system:his:add")
    @Log(title = "护士处置记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TPrescriptionNurseHis tPrescriptionNurseHis)
    {
        return toAjax(tPrescriptionNurseHisService.insertTPrescriptionNurseHis(tPrescriptionNurseHis));
    }

    /**
     * 修改护士处置记录
     */
    @RequiresPermissions("system:his:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        TPrescriptionNurseHis tPrescriptionNurseHis = tPrescriptionNurseHisService.selectTPrescriptionNurseHisById(id);
        mmap.put("tPrescriptionNurseHis", tPrescriptionNurseHis);
        return prefix + "/edit";
    }

    /**
     * 修改保存护士处置记录
     */
    @RequiresPermissions("system:his:edit")
    @Log(title = "护士处置记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TPrescriptionNurseHis tPrescriptionNurseHis)
    {
        return toAjax(tPrescriptionNurseHisService.updateTPrescriptionNurseHis(tPrescriptionNurseHis));
    }

    /**
     * 删除护士处置记录
     */
    @RequiresPermissions("system:his:remove")
    @Log(title = "护士处置记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(tPrescriptionNurseHisService.deleteTPrescriptionNurseHisByIds(ids));
    }
}
